home *** CD-ROM | disk | FTP | other *** search
/ Freelog 115 / FreelogNo115-MaiJuin2013.iso / Internet / Filezilla Server / FileZilla_Server-0_9_41.exe / source / interface / OptionsGeneralWelcomemessagePage.cpp < prev    next >
C/C++ Source or Header  |  2011-11-06  |  4KB  |  105 lines

  1. // FileZilla Server - a Windows ftp server
  2.  
  3. // Copyright (C) 2002-2004 - Tim Kosse <tim.kosse@gmx.de>
  4.  
  5. // This program is free software; you can redistribute it and/or
  6. // modify it under the terms of the GNU General Public License
  7. // as published by the Free Software Foundation; either version 2
  8. // of the License, or (at your option) any later version.
  9.  
  10. // This program is distributed in the hope that it will be useful,
  11. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13. // GNU General Public License for more details.
  14.  
  15. // You should have received a copy of the GNU General Public License
  16. // along with this program; if not, write to the Free Software
  17. // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  18.  
  19. // OptionsGeneralWelcomemessagePage.cpp: Implementierungsdatei
  20. //
  21.  
  22. #include "stdafx.h"
  23. #include "filezilla server.h"
  24. #include "OptionsDlg.h"
  25. #include "OptionsPage.h"
  26. #include "OptionsGeneralWelcomemessagePage.h"
  27.  
  28. #if defined(_DEBUG) && !defined(MMGR)
  29. #define new DEBUG_NEW
  30. #undef THIS_FILE
  31. static char THIS_FILE[] = __FILE__;
  32. #endif
  33.  
  34. /////////////////////////////////////////////////////////////////////////////
  35. // Dialogfeld COptionsGeneralWelcomemessagePage 
  36.  
  37.  
  38. COptionsGeneralWelcomemessagePage::COptionsGeneralWelcomemessagePage(COptionsDlg *pOptionsDlg, CWnd* pParent /*=NULL*/)
  39.     : COptionsPage(pOptionsDlg, COptionsGeneralWelcomemessagePage::IDD, pParent)
  40.     , m_hideWelcomeMessage(FALSE)
  41. {
  42.     //{{AFX_DATA_INIT(COptionsGeneralWelcomemessagePage)
  43.     m_WelcomeMessage = _T("");
  44.     //}}AFX_DATA_INIT
  45. }
  46.  
  47.  
  48. void COptionsGeneralWelcomemessagePage::DoDataExchange(CDataExchange* pDX)
  49. {
  50.     COptionsPage::DoDataExchange(pDX);
  51.     //{{AFX_DATA_MAP(COptionsGeneralWelcomemessagePage)
  52.     DDX_Text(pDX, IDC_OPTIONS_GENERAL_WELCOMEMESSAGE_WELCOMEMESSAGE, m_WelcomeMessage);
  53.     DDV_MaxChars(pDX, m_WelcomeMessage, 7500);
  54.     //}}AFX_DATA_MAP
  55.     DDX_Check(pDX, IDC_OPTIONS_WELCOMEMESSAGE_HIDE, m_hideWelcomeMessage);
  56. }
  57.  
  58.  
  59. BEGIN_MESSAGE_MAP(COptionsGeneralWelcomemessagePage, COptionsPage)
  60.     //{{AFX_MSG_MAP(COptionsGeneralWelcomemessagePage)
  61.         // HINWEIS: Der Klassen-Assistent fⁿgt hier Zuordnungsmakros fⁿr Nachrichten ein
  62.     //}}AFX_MSG_MAP
  63. END_MESSAGE_MAP()
  64.  
  65. /////////////////////////////////////////////////////////////////////////////
  66. // Behandlungsroutinen fⁿr Nachrichten COptionsGeneralWelcomemessagePage 
  67.  
  68. void COptionsGeneralWelcomemessagePage::LoadData()
  69. {
  70.     m_WelcomeMessage = m_pOptionsDlg->GetOption(OPTION_WELCOMEMESSAGE);
  71.     m_hideWelcomeMessage = m_pOptionsDlg->GetOptionVal(OPTION_WELCOMEMESSAGE_HIDE) != 0;
  72. }
  73.  
  74. void COptionsGeneralWelcomemessagePage::SaveData()
  75. {
  76.     CString msg = m_WelcomeMessage;
  77.     std::list<CString> msgLines;
  78.     int oldpos = 0;
  79.     msg.Replace(_T("\r\n"), _T("\n"));
  80.     int pos = msg.Find(_T("\n"));
  81.     CString line;
  82.     while (pos != -1)
  83.     {
  84.         if (pos)
  85.         {
  86.             line = msg.Mid(oldpos, pos - oldpos);
  87.             line = line.Left(CONST_WELCOMEMESSAGE_LINESIZE);
  88.             line.TrimRight(_T(" "));
  89.             if (msgLines.size() || line != _T(""))
  90.                 msgLines.push_back(line);
  91.         }
  92.         oldpos = pos + 1;
  93.         pos = msg.Find(_T("\n"), oldpos);
  94.     }
  95.     line = msg.Mid(oldpos);
  96.     if (line != _T(""))
  97.         msgLines.push_back(line);
  98.     msg = _T("");
  99.     for (std::list<CString>::iterator iter = msgLines.begin(); iter != msgLines.end(); iter++)
  100.         msg += *iter + _T("\r\n");
  101.     msg.TrimRight(_T("\r\n"));
  102.  
  103.     m_pOptionsDlg->SetOption(OPTION_WELCOMEMESSAGE, msg);
  104.     m_pOptionsDlg->SetOption(OPTION_WELCOMEMESSAGE_HIDE, m_hideWelcomeMessage);
  105. }